using System.Drawing;
using System.Windows.Forms;

class Program {
    static void Main(){
        var f = new MyForm();
        // 被OnPaint覆盖
        f.Paint += new PaintEventHandler(p);

        Application.Run(f);
    }

    static void p(object objSender,PaintEventArgs e){
        var t = (Form)objSender;
        var g = e.Graphics;
        g.DrawString("my Paint",t.Font,Brushes.Black,0,100);
    }
}

class MyForm : Form {
    public MyForm(){
        Text = "MyForm1";
        BackColor = Color.Red;
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        var g = e.Graphics;
        g.DrawString("Hello forms",Font,Brushes.Black,0,0);
    }
}